# Maintainer: David Runge <dvzrv@archlinux.org>

_name=django-appconf
pkgname=python-django-appconf
pkgver=1.0.5
pkgrel=4
pkgdesc="An app to handle configuration defaults of packaged Django apps gracefully"
arch=('any')
url="https://github.com/django-compressor/django-appconf"
license=('BSD')
depends=('python-django' 'python-six')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('9d1b01e3f8dac5a9a7f6f4f5c0e9fcf4a2a0177e7702e5f932f238379bd2bb065a698c86d27c2dbab7ba6480abdc25595c8a4f7c6f0524517aeb1c0e34f09864')
b2sums=('4d031a229ab11d55d85887346cf208cbe1136e48b78a4c096ba6d67017d80031d634cbeef82783713e4e005fe8a19f1f8e12193450b04e968b8ea5a94290f2bc')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="${PWD}:build:${PYTHONPATH}"
  DJANGO_SETTINGS_MODULE=tests.test_settings django-admin test -v2 tests
  rm -rf tests/__pycache__
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --optimize=1 --root="${pkgdir}"
  install -vDm 644 {AUTHORS,README.rst} -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
